package com.eaoa.uc.busorder.bo;

import java.math.BigDecimal;
import java.util.List;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.dao.bus.BusCargoDAO;
import com.eaoa.vo.bus.BusCargo;

public class BusCargoModifyBO extends EABaseBusinessObject{
	private static BusCargoDAO cargoDAO = new BusCargoDAO();
	private List cargos;

	public BusCargoModifyBO(List cargos) {
		super();
		this.cargos=cargos;

	}
	
	protected void performBusinessLogic() {
		
		//calculate size
		for(int i=0 ; i<cargos.size(); i++){
			BusCargo cargo =  (BusCargo)cargos.get(i);
			if(cargo.getLength()!=null && cargo.getWidth()!=null && cargo.getHigh()!=null){
				BigDecimal size = cargo.getLength().multiply(cargo.getWidth()).multiply(cargo.getHigh());
				cargo.setSize(size);
			}
		}
		
		cargoDAO.saveOrUpdateBatch(cargos);
	}
}
